package com.sojpt.boot.controller.business.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
import com.sojpt.model.LkyMajor;

/*
 * MW
 * */
public class LkyMajorAddValidator extends Validator {

    @Override
    protected void validate(Controller c) {

        LkyMajor lkyMajor = c.getModel(LkyMajor.class, "lkyMajor");

        if(lkyMajor.get("name") != null)
            validateString("lkyMajor.name", 0, 20, "msg", "专业名称 最多20个字符");
        if(lkyMajor.get("major_number") != null)
            validateString("lkyMajor.major_number", 0, 20, "msg", "专业编号 最多20个字符");
        if(lkyMajor.get("remark_info") != null)
            validateString("lkyMajor.remark_info", 0, 200, "msg", "备注信息 最多200个字符");

    }

    @Override
    protected void handleError(Controller c) {
        c.renderJson();
    }

}